<?php 
if(!isset($geoMap) || !is_object($geoMap))
{
	$html->initHelper("GeoMap");
	$geoMap = $html->GeoMap;
}
$region = '';
if(cr('Geo.region'))
{
	$region = 'region='.cr('Geo.region');
}
if(!isset($this->params['isAjax']) || !$this->params['isAjax'])
{
?>
	<script type="text/javascript" src="<?php echo 'http://maps.google.com/maps/api/js?sensor=false&'.$region?>"></script>
	<script type="text/javascript" src="<?php echo $html->url("/js/geomap.js")?>"></script>
	<script type="text/javascript" src="<?php echo $html->url("/js/infobubble.js")?>"></script>
	<link rel="stylesheet" type="text/css" href="<?php echo $html->url('/css/geomap.css')?>" />
<?php 
}
if(!isset($width))
{
	$width = "100%";
}
if(!isset($height))
{
	$height  = "300px";
}
if(!isset($allowTravelModeChange))
{
	$allowTravelModeChange = true;
}
$travelModeOptions = array(
	'google.maps.TravelMode.DRIVING' => 'For standard driving directions using the road network',
	'google.maps.TravelMode.BICYCLING' => 'For bicycling directions via bicycle paths & preferred streets',
	'google.maps.TravelMode.TRANSIT' => 'For directions via public transit routes',
	'google.maps.TravelMode.WALKING' => 'For walking directions via pedestrian paths & sidewalks'
);

$makers = $geoMap->getListingsMarker(array($listingData));
$makersJson = $javascript->object($makers); ?>
<h2> Get Directions</h2>
<div id="map_container_index" class="">
	<div id="map_index" style="<?php echo "width:".$width.";height:".$height.";z-index:100;"?>">
	
	</div>
	<div id="config_strip">
		<br/>
		<?php 
			if($allowTravelModeChange)
			{
				echo $form->input("travel_mode",array("label"=>__("Travel Mode"),"id"=>"TravelMode",'type'=>"select","options"=>$travelModeOptions));
			}
			echo $form->input("source_address",array("label"=>__("Source address"),"id"=>"SourceAddress","type"=>"text","style"=>"width:99%;"));
			echo $form->input("swap_points",array("label"=>__("Swap start/end points"),"id"=>"SwapPoints","type"=>"checkbox"));
			?>
			<a id="getDirectionsBtn" class="button"><?php echo __("Get directions"); ?></a>
		
		<div class="clear"></div><br/>
		<div><?php echo __("Total Distance");?>: <span id="total_distance_div"></span></div>
		<div id="direction_details_div" class="direction_details">
		</div>
	</div>
</div>
<script>
	var allowTravelModeChange = <?php echo $allowTravelModeChange ? "true" : "false"; ?>;
	$(document).ready(function(){
		makeMapForGetDirection('map_index',<?php echo $makersJson ?>, <?php echo $listingData["Listing"]["lat"] ?>, <?php echo $listingData["Listing"]["lng"] ?>, allowTravelModeChange);
	})
</script>